package com.buymobile.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.buymobile.dao.PropertyDAO;
import com.buymobile.domain.Property;
import com.buymobile.service.PropertyService;

public class PropertyServiceImpl implements PropertyService {

	private PropertyDAO propertyDAO;
	
	@Override
	public void addProperty(Property property) {
		propertyDAO.insert("property.insertProperty",property);
		
	}

	@Override
	public void deleteTypeProperty(Integer id) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public Property getPropertyById(Integer id) {
		return (Property)propertyDAO.queryForObject("property.getPropertyById", id);
	}

	@Override
	public void updateProperty(Property property) {
		propertyDAO.update("property.updateProperty", property);
		
	}

	@Override
	public List<Property> listPropertiesByTypeId(Integer typeId) {
		Map<String,Object> criteria = new HashMap<String,Object>();
		criteria.put("type_id", typeId);
		return (List<Property>)propertyDAO.queryForList("property.queryProperties", criteria);
	}

	public void setPropertyDAO(PropertyDAO propertyDAO) {
		this.propertyDAO = propertyDAO;
	}

}
